<?php

/**
 * AgencyCMS routes file
 *
 * @package       AgencyCMS
 * @subpackage    AgencyCMS.config
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */

Router::connectNamed(array(
    'page',
    'sort',
    'direction'
));

// homepage
Router::connect('/', array(
    'controller' => 'agency_pages',
    'action'     => 'home'
));

/**
 * Admin routes
 */

// load the admin routing prefix from core settings
$adminPrefix = Configure::read('Agency.admin_url');

// admin dashboard
Router::connect("/{$adminPrefix}", array(
    'controller' => 'agency_dashboards',
    'action'     => 'index',
    'prefix'     => 'admin',
    'admin'      => true
));

// list of controllers used by Agency to avoid URL clashes with app
$adminControllers = array(
    'pages',
    'users'
);
foreach ($adminControllers as $controller) {
    Router::connect("/{$adminPrefix}/{$controller}/:action/*", array(
        'controller' => "agency_{$controller}",
        'prefix'     => 'admin',
        'admin'      => true
    ));
}